package cn.yuanqiao.web.controller.archive.management;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.management.domain.YqXzjl;
import cn.yuanqiao.archive.management.service.IYqXzjlService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 下载记录Controller
 * 
 * @author sy
 * @date 2023-12-27
 */
@RestController
@RequestMapping("/archive/yqXzjl")
public class YqXzjlController extends BaseController
{
    @Autowired
    private IYqXzjlService yqXzjlService;

    /**
     * 查询下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:yqXzjl:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqXzjl yqXzjl)
    {
        startPage();
        List<YqXzjl> list = yqXzjlService.selectYqXzjlList(yqXzjl);
        return getDataTable(list);
    }

    /**
     * 导出下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:yqXzjl:export')")
    @Log(title = "下载记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqXzjl yqXzjl)
    {
        List<YqXzjl> list = yqXzjlService.selectYqXzjlList(yqXzjl);
        ExcelUtil<YqXzjl> util = new ExcelUtil<YqXzjl>(YqXzjl.class);
        util.exportExcel(response, list, "下载记录数据");
    }

    /**
     * 获取下载记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:yqXzjl:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yqXzjlService.selectYqXzjlById(id));
    }

    /**
     * 新增下载记录
     */
    @PreAuthorize("@ss.hasPermi('archive:yqXzjl:add')")
    @Log(title = "下载记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqXzjl yqXzjl)
    {
        return toAjax(yqXzjlService.insertYqXzjl(yqXzjl));
    }

    /**
     * 修改下载记录
     */
    @PreAuthorize("@ss.hasPermi('archive:yqXzjl:edit')")
    @Log(title = "下载记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqXzjl yqXzjl)
    {
        return toAjax(yqXzjlService.updateYqXzjl(yqXzjl));
    }

    /**
     * 删除下载记录
     */
    @PreAuthorize("@ss.hasPermi('archive:yqXzjl:remove')")
    @Log(title = "下载记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yqXzjlService.deleteYqXzjlByIds(ids));
    }
}
